#include<iostream>
#include<fstream>
#include<vector>
#include<set>
#include<string>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<ctime> 
using namespace std;
vector<string> save_words;
vector<string> unknow_words;
void get_DB(string filename)
{
	if(filename=="NULL")
		return ;
	fstream file(filename.c_str(),ios::in);
	string str;
	while(file>>str)
	{
		save_words.push_back(str);
		str.clear();
	}
	sort(save_words.begin(),save_words.end());
	
	file.close();
}
void save_DB(string filename)
{
	fstream file(filename.c_str(),ios::out);
	for(int i=0;i<(int)unknow_words.size();i++)
	{
		save_words.push_back(unknow_words[i]);
	}
	sort(save_words.begin(),save_words.end());
	vector<string>::iterator buf=unique(save_words.begin(),save_words.end());
	save_words.erase(buf,save_words.end());
	for(int i=0;i<(int)save_words.size();i++)
	{
		file<<save_words[i]<<endl;
	}
	
	file.close();
}
void exam()
{
	cout<<"let us have a test"<<endl;
	int n;
	cout<<"please input the number of the words that you want to exam yourself"<<endl;
	cin>>n;
	srand(time(NULL)+n);
	system("cls");
	for(int i=1;i<=n;i++)
	{
		int r=rand()%save_words.size();
		cout<<save_words[r]<<endl;
		system("pause");
		system("cls");
	}
	cout<<"the exam is over"<<endl;
}
int main()
{
	string str;
	cout<<"input your DB's name.if you don't have DB ,input NULL"<<endl;
	cin>>str;
	get_DB(str);
	exam();
	return 0;
}
